package com.kgc.work.workmanagerweb.controller;

import com.kgc.work.bean.Workorder;
import com.kgc.work.service.WorkService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class WorkController {

    @Reference
    WorkService workService;
    @RequestMapping("/addWork")
    public String addWork(@RequestBody Workorder workorder){
        workorder.setCreatedate(new Date());
        Integer integer = workService.addWork(workorder);
        if(integer>0){
            return "success";
        }else{
            return "fail";
        }
    }


    @RequestMapping("/seleWork")
    public List<Workorder> seleWork(){
        List<Workorder> allWork = workService.getAllWork();
        return allWork;
    }
}
